<?php
/**
 * 更新 配置 文件;  
 *
 * @filesource update.php
 * @package peck 
 * @subpackage 
 * @version $id: 0.1, utf8, Fri Jun 25 14:20:20 CST 2010$
 * @author LD King <kldscs[at]gmail.com>
 * @example 
 *   
 */

require_once 'Zend/Config/Ini.php';
$config = new Zend_Config_Ini('application.ini');
$basedir = dirname(__FILE__);
## environments
foreach( $config as $file=>$data) {
    $file = $basedir.DIRECTORY_SEPARATOR.$file.'.inc.php'; 
    $data = '<?php $GLOBALS[\'__configs\'] = ' . var_export($data->toArray(), true) . ';';


    $patterns = array ('/\'APPLICATION_PATH\./', '/\'APPLICATION_PREPATH\./', );
    $replace = array ('APPLICATION_PATH.\'', 'APPLICATION_PREPATH.\'', );
    $data = preg_replace($patterns, $replace, $data);

    file_put_contents($file, $data, LOCK_EX);
    //file_put_contents($file, php_strip_whitespace($data), LOCK_EX);
    clearstatcache();
}

?>
